package com.bruce.cloud.feign.client;

import org.springframework.retry.support.RetryTemplate;

import java.io.IOException;

/**
 * Created by bruce in 2025/6/27 16:08
 */
public class RetryTemplateFactory {

    private static RetryTemplate template;

    public static RetryTemplate get() {
        if (template != null) {
            return template;
        }
        RetryTemplate template = RetryTemplate.builder()
                .maxAttempts(2)
                .exponentialBackoff(1000, 2, 10000, true)
                .withListener(new LogRetryListener())
                .retryOn(IOException.class)
                .build();
        RetryTemplateFactory.template = template;
        return template;
    }


}
